class TagsController < ApplicationController
  # Lists the 100 most popular tags on flickr for the user's photos
  # It also finds the tag with the maximum number of photos
  # This information is used to show the tags with weighted font sizes while rendering the view.
  def index
    @gallery = Gallery.instance
    @tag_list = @gallery.flickr.tags.getListUserPopular(LIGHTBOX_CONFIG[:flickr_user_id],100)
    @max =0
    @tag_list.each do |tag|
      @max = tag[1] if tag[1] > @max
    end
  end
  # Returns a list of photos for a tag
  def list
    if params[:id]
     @gallery = Gallery.instance
     @tag = params[:id]
     @photos = @gallery.flickr.photos.search(LIGHTBOX_CONFIG[:flickr_user_id],params[:id],
                                             nil,nil,nil,nil,nil,nil,nil,nil,500,nil,'date-posted-asc')
    else
      redirect_to(:action => 'index')
    end
  end
  
end
